<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>注册页面</title>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script>
        function checkUsername() {
            var username = $("#id").val();
            $.ajax({
                url: "checkUsername",
                type: "GET",
                data: { id: username },
                success: function(response) {
                    if (response === "exists") {
                        alert("用户名已存在！");
                    }
                }
            });
        }
    </script>
</head>
<body>
    <h2>用户注册</h2>
    <c:if test="${not empty errorMessage}">
        <p style="color: red;">${errorMessage}</p>
    </c:if>
    <form action="register" method="post">
        用户名: <input type="text" name="id" id="id" onblur="checkUsername()"><br>
        姓名: <input type="text" name="name"><br>
        密码: <input type="password" name="password"><br>
        邮箱: <input type="text" name="email"><br>
        性别: <input type="text" name="gender"><br>
        生日: <input type="date" name="birthday"><br>
        擅长语言: <input type="text" name="lans"><br>
        <input type="submit" value="注册">
    </form>
</body>
</html>